Skip to content

Consolidate v1 MCP client utilities - #2467

Merged
xeophon merged 5 commits into
mainfrom
xeophon/consolidate-mcp-client
Aug 31, 2026
Merged

Consolidate v1 MCP client utilities#2467
xeophon merged 5 commits into
mainfrom
xeophon/consolidate-mcp-client

Conversation

@xeophon

@xeophon xeophon commented Aug 29, 2026

Copy link
Copy Markdown
Member

Overview

Consolidates v1 MCP client utilities and standalone harness code behind shared owning modules.

Details

  • Exposes mcp_client, with_retry, connect_mcp, mcp_content_to_chat_content, and call_mcp from verifiers.v1.mcp.
  • Preserves the existing per-call client, timeout, teardown, naming, image conversion, and at-least-once retry behavior.
  • Embeds the public client source after PEP 723 metadata so standalone sandbox programs retain their declared dependency isolation.
  • Shares one minimal program between Null and Bash and centralizes the common host-side launch path.
  • Reuses the public client helper from NeMo Gym and removes the duplicate MCP implementations from Null, Bash, Browser Use, and NeMo Gym.

Related work

Closes #2202


Note

Medium Risk
Touches eval harness launch paths and MCP tool wiring across Null, Bash, Browser Use, and NeMo Gym; behavioral differences between Null and Bash modes in the unified program warrant careful regression testing.

Overview
Moves duplicated MCP HTTP client, retry, tool discovery, and call helpers into verifiers.v1.mcp.client, re-exported from verifiers.v1.mcp, and wires NeMo Gym’s upstream MCP calls through that shared mcp_client instead of a local session helper.

Adds standalone.py with launch_chat_program (shared CLI/MCP/initial-messages launch path) and inline_mcp_client (splices the client module source into PEP 723 sandbox scripts). Null and Bash now share minimal/program.py (Bash passes --bash plus edit/search/interception flags); null/program.py is removed. Browser Use drops its inlined MCP copy and uses the same embed + launch_chat_program pattern.

The shared minimal program keeps Null-specific behavior when --bash is off (60s MCP enumeration cap, graceful exit on context-overflow API errors) and Bash-specific behavior when on (longer HTTP timeouts, unbounded MCP connect wait, local tools gated by flags).

Reviewed by Cursor Bugbot for commit 1944f34. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Consolidate v1 MCP client utilities into shared client.py and launch_chat_program

  • Adds a reusable MCP client in client.py with mcp_client, with_retry, connect_mcp, mcp_content_to_chat_content, and call_mcp helpers, replacing per-harness duplicates
  • Adds standalone.launch_chat_program and inline_mcp_client in standalone.py to centralize wire-argument passing and embed the MCP client into PEP 723 scripts at build time
  • Refactors the bash, browser_use, and null harnesses to call launch_chat_program with the shared minimal.PROGRAM_SOURCE; deletes the standalone null program
  • Unifies minimal/program.py to serve both Null and Bash harnesses via a --bash flag that enables bash tooling, unbounded MCP enumeration, and longer model timeout; without it, bash tooling is disabled and context-overflow errors terminate cleanly
  • Refactors NeMoGymToolset.list_tools/call_tool in toolset.py to use the shared mcp_client helper with explicit timeouts
  • Risk: minimal.program now relies on inlined shared functions (mcp_client, with_retry, connect_mcp, call_mcp, mcp_content_to_chat_content) being present at runtime via inline_mcp_client; if PROGRAM_SOURCE is constructed without calling inline_mcp_client, the script will fail with NameError

Macroscope summarized 1944f34.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-31T17:24:06.665984Z 1944f34 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b9f3f24d00

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/mcp/client.py Outdated
@macroscopeapp

macroscopeapp Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This cross-cutting refactor changes shared MCP client infrastructure and launch behavior across several production harnesses, including Null/Bash mode selection, generated-script source injection, and NeMo Gym timeout handling. The scope and runtime reach warrant human review despite most helper logic being consolidated from existing implementations.

You can add or adjust custom eligibility rules. Learn more.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 798ea7cda8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/mcp/client.py Outdated
@xeophon
xeophon requested a review from mikasenghaas August 30, 2026 15:32
@xeophon
xeophon enabled auto-merge (squash) August 30, 2026 15:34
@xeophon
xeophon disabled auto-merge August 31, 2026 18:13
@xeophon
xeophon merged commit a205eb3 into main Aug 31, 2026
16 of 17 checks passed
@xeophon
xeophon deleted the xeophon/consolidate-mcp-client branch August 31, 2026 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v1: mcp utils

2 participants